#!/bin/env/python3
import logging
from datetime import timedelta

from redis import StrictRedis


# 设置配置信息（基类配置信息）
class Config(object):
    # 调试信息
    DEBUG = True
    SECRET_KEY = "thisissecret"
    # 数据库配置信息
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:3254983@zhangtiantian.cc:3306/db_news"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True  # 每当数据库的时候，视图函数结束的时候都会提交
    # redis 配置信息
    REDIS_HOST = "zhangtiantian.cc"
    REDIS_PORT = 6379
    # SERVER_NAME = '127.0.0.1:5001'
    # session配置信息
    SESSION_TYPE = "redis"  # 存储类型
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    SESSION_USE_SIGNER = True  # 设置签名存储
    PERMANENT_SESSION_LIFETIME = timedelta(days=2)  # session有效期

    LEVEL_NAME = logging.DEBUG


# 开发环境配置信息
class DevelopConfig(Config):
    pass


# 生产(线上)环境配置信息
class ProductConfig(Config):
    DEBUG = False
    LEVEL_NAME = logging.ERROR


# 测试环境配置信息
class TestConfig(Config):
    pass


# 提供一个统一的访问入口:
config_dict = {
    "develop": DevelopConfig,
    "product": ProductConfig,
    "test": TestConfig
}
